package com.example.recuitactivity.adapter;

import android.content.Context;
import android.content.Intent;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.recuitactivity.InterviewNotifyActivity;
import com.example.recuitactivity.R;

import com.example.recuitactivity.bean.Interview;

import java.util.List;

public class CandidateInterviewAdapter extends RecyclerView.Adapter<CandidateInterviewAdapter.InterviewInfoViewHolder>{
    private List<Interview> mDatas;
    private Context context;

    public CandidateInterviewAdapter(){}
    public CandidateInterviewAdapter(Context context, List<Interview> mDatas) {
        this.context = context;
        this.mDatas = mDatas;
    }

    public void setmDatas(List<Interview> mDatas){
        this.mDatas=mDatas;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public InterviewInfoViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.rv_interview_notify_row_item, parent, false);
        InterviewInfoViewHolder holder = new InterviewInfoViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(@NonNull InterviewInfoViewHolder holder, int position) {
        Interview bean = mDatas.get(position);
        holder.tv_company.setText(bean.getEnterprise());
        holder.tv_time.setText(bean.getSendTime());
        holder.iv_email.setImageResource(R.drawable.notify);
        holder.tv_search_detail.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent(context, InterviewNotifyActivity.class);
                intent.putExtra("interview_id",bean.getId());
                context.startActivity(intent);
            }
        });

    }

    @Override
    public int getItemCount() {
        return mDatas.size();
    }

    class InterviewInfoViewHolder extends RecyclerView.ViewHolder {
        TextView tv_company,tv_time,tv_search_detail;
        ImageView iv_email;
        public InterviewInfoViewHolder(@NonNull View itemView) {
            super(itemView);
            tv_company=(TextView) itemView.findViewById(R.id.tv_interview_company);
            tv_time=(TextView) itemView.findViewById(R.id.tv_interview_sendtime);
            tv_search_detail=(TextView) itemView.findViewById(R.id.tv_interview_search_detail);
            iv_email=(ImageView) itemView.findViewById(R.id.imageView5);
        }
    }

}
